package artiko.ai.posizionamento.rafforzamentoIniziale;
import java.io.*;

import jpl.Atom;
import jpl.PrologException;
import jpl.Query;
import jpl.Term;
import jpl.Variable;


public class Prova {

	/**
	 * @param args
	 * @throws IOException 
	 */
	@SuppressWarnings("deprecation")
	public static void main(String[] args) throws IOException {
	/*	Query q1 = 
			    new Query( 
			        "consult", 
			        new Term[] {new Atom("C:\\Users\\Carmine\\workspace_1\\Artiko\\artiko_resources\\Base_RafforzamentoIniziale\\baseDiProva.pl")} 
			    );
		System.out.println( "consult " + (q1.query() ? "succeeded" : "failed"));
		
		Query q2 = 
			    new Query( 
			        "child_of", 
			        new Term[] {new Atom("joe"),new Atom("ralf")} 
			    );
			System.out.println( 
			    "child_of(joe,ralf) is " + 
			    ( q2.query() ? "provable" : "not provable" ) 
			);
			
			Query q3 = 
				    new Query( 
				        "descendent_of", 
				        new Term[] {new Atom("steve"),new Atom("ralf")} 
				    );
				System.out.println( 
				    "descendent_of(joe,ralf) is " + 
				    ( q3.query() ? "provable" : "not provable" ) 
				);*/
		

		Query q1 = 
			    new Query( 
			        "consult", 
			        new Term[] {new Atom("artiko_resources\\Base_RafforzamentoIniziale\\base.pl")} 
			    );
		
		System.out.println( "consult " + (q1.query() ? "succeeded" : "failed"));
		q1.close();
			
		
		// q4 = country vittima
		
		Variable X = new Variable("X");
		 Term arg[] = { X };
		
			try{	
		Query q4 = 
			    new Query( 
			        "terrAttaccante", 
			        arg //new Term[]{new Atom("n7")} 
			    );

	
		if(q4.hasMoreElements()){
			String element = q4.nextElement().toString();
			
			if(element.length() == 7){
				System.out.println(element.substring(4, 6));
			}
			else{
				System.out.println(element.substring(4, 5));
			}
			
			
			
			
		while(q4.hasMoreElements()){

		element = q4.nextElement().toString();
			
			if(element.length() == 7){
				System.out.println(element.substring(4, 6));
			}
			else{
				System.out.println(element.substring(4, 5));
			}
			
			
				}
		}
		else{
			System.out.println("niente");
		}
			
			}
			catch(PrologException e){
				System.out.println("vuota");
			}
		
	}
	//	
				

	

}
